package com.example.demo_2.Dao;

import com.example.demo_2.Entity.Stu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

//@Repository
//public class StuDao {
//    @Autowired
//    JdbcTemplate jdbcTemplate;
//
//    public Stu getUserByName(String Name) {
//        String sql = "select * from mess where name = ?";
//        return jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(Stu.class), Name);
//    }
//}
//添加Mapper注解，让UserDao接口，成为Mybatis映射器接口
@Mapper
public interface StuDao {
    @Select("select * from user where username = #{username}")
    Stu getUserByName(String username);
}